@REM -- ==============================================================================
@REM --  DESCRIPTION:                                                                     
@REM --     SYSGEN dependency filtering for FusionWare::BSP                                                                              
@REM --                                                                                   
@REM --  Legal Notices:                                                                   
@REM --     Copyright (C) 2000-2006, EmbeddedFusion                                            
@REM --     ALL RIGHTS RESERVED                                                           
@REM --                                                                                   
@REM --     This file, software, or program is supplied under the terms of a              
@REM --     license agreement and/or nondisclosure agreement with EmbeddedFusion          
@REM --     and may not be copied or disclosed except in accordance with the terms
@REM --     of that agreement.  This file, software, or program contains
@REM --     copyrighted material and/or trade secret information of EmbeddedFusion,
@REM --     and must be treated as such. EmbeddedFusion reserves all rights in this
@REM --     material, except as the license agreement or nondisclosure agreement
@REM --     specifically indicate.                                
@REM --                                                                                   
@REM --     All rights reserved.  No part of this program or publication may be           
@REM --     reproduced, transmitted, transcribed, stored in a retrieval system            
@REM --     retrieval system, or translated into any language or computer                 
@REM --     language, in any form or by any means, electronic, mechanical,                
@REM --     magnetic, optical, chemical, manual, or otherwise, without the prior          
@REM --     written permission of EmbeddedFusion.                                         
@REM --                                                                                   
@REM --  Disclaimer:                                                                      
@REM --     EmbeddedFusion makes no warranty of any kind regarding                        
@REM --     this code.  This code is provided on an "As Is" basis and                     
@REM --     EmbeddedFusion will not provide any support assistance,                       
@REM --     installation, training or other services.                                     
@REM --     EmbeddedFusion does not provide any updates, enhancements                     
@REM --     or extensions. EmbeddedFusion specifically disclaims any                      
@REM --     warranty of merchantability, non-infringement, fitness for any                
@REM --     particular purpose, or any other warranty.                                    
@REM --                                                                                   
@REM --     EmbeddedFusion disclaims all liability, including liability                   
@REM --     for infringement of any proprietary rights, relating to use of the            
@REM --     code. No license, express or implied, by estoppel or otherwise,               
@REM --     to any intellectual property rights is granted herein.                        
@REM --                                                                                   
@REM --     EmbeddedFusion has no responsibility under warranty, indemnification          
@REM --     or otherwise, for the modification or customization of any EmbeddedFusion     
@REM --     software by EmbeddedFusion, customer, website user or any third party even    
@REM --     if such customization and/or modification is done using EmbeddedFusion tools, 
@REM --     training or methods documented by EmbeddedFusion.                             
@REM --                                                                                          
@REM --  Remarks:
@REM --     This file is called from within the CESYSGEN.BAT of
@REM --     of platforms based on CEBASE. It is used to configure
@REM --     the FUSIONWARE_MODULES environment var for the sysgen makefile
@REM -- 
@REM --  Usage:
@REM -- 		cebasecesysgen (preproc | pass1 | pass2 | report)
@REM -- --------------------------------------------------------------------

@REM -- --------------------------------------------------------------------
@REM --  Main function for the script.
@REM --  This simply checks the SYSGEN stage 
@REM --  and calls the appropriate handler for it. 
if /i "%1"=="preproc" call :DoPreproc
if /i "%1"=="pass1" call :DoPass1
if /i "%1"=="pass2" call :DoPass2
if /i "%1"=="report" call :DoReport
goto :EOF

@REM -- ======================================================================================
@REM --  "preproc" is passed *BEFORE* most of CESYSGEN.BAT has RUN; it
@REM --   should not set any of the *_MODULES values as the first thing CESYSGEN.BAT
@REM --   does after this is called is clear all of them. Various system dependencies
@REM --   should be tested here.
@REM -- ======================================================================================
:DoPreProc
SET FUSIONWARE_MODULES=
SET FUSIONWARE_BOOT_COMPONENTS=
SET FUSIONWARE_OAL_COMPONENTS=
SET FUSIONWARE_DEVICE_COMPONENTS=
SET FUSIONWARE_DFX_COMPONENTS=
SET FUSIONWARE_KITL_COMPONENTS=
goto :EOF

@REM -- =====================================================================================
@REM --  Remarks:
@REM --     "pass1" is passed before most of CESYSGEN.BAT has RUN and it's auto dpendency
@REM --      setup is completed. Set up SYSGEN_xxx dependencies and SYSGEN_FUSIONWARE_ flags as needed
@REM --      *DO NOT* Build up the FUSIONWARE_MODULES list at this stage
@REM --      To avoid label name clashes ALWAYS Use  a trailing _1 for all labels in this section
@REM -- =====================================================================================
:DoPass1
if "%BSP_FUSIONWARE_POWER_BUTTON%"=="1" SET SYSGEN_FUSIONWARE_DFX=1

@REM -- CPU specific settings

@REM -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@REM -- Freescale i.MXL specific
if "%SYSGEN_FUSIONWARE_BOOT_IMXL%"=="1" set __CPU_iMXL=1
if "%SYSGEN_FUSIONWARE_OAL_IMXL%"=="1" set __CPU_iMXL=1
if "%SYSGEN_FUSIONWARE_BOOT_PXA25X%"=="1" set __CPU_PXA25X=1
if "%SYSGEN_FUSIONWARE_OAL_PXA25X%"=="1" set __CPU_PXA25X=1
if "%SYSGEN_FUSIONWARE_BOOT_PXA27X%"=="1" set __CPU_PXA27X=1
if "%SYSGEN_FUSIONWARE_OAL_PXA27X%"=="1" set __CPU_PXA27X=1

if not "%__CPU_iMXL%"=="1" goto nomxl_1
if "%SYSGEN_FUSIONWARE_BOOT_IMXL%"=="1" set SYSGEN_FUSIONWARE_BOOT=1
if "%SYSGEN_FUSIONWARE_OAL_IMXL%"=="1" set SYSGEN_FUSIONWARE_OAL=1
if "%BSP_FUSIONWARE_MXL_UART1%"=="1" SET SYSGEN_FUSIONWARE_MXL_SERIAL=1
if "%BSP_FUSIONWARE_MXL_UART2%"=="1" SET SYSGEN_FUSIONWARE_MXL_SERIAL=1

if "%SYSGEN_FUSIONWARE_MXL_SERIAL%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
:nomxl_1 

@REM -- Intel PXA25X specific
if not "%__CPU_PXA25X%"=="1" goto noPXA25X_1
if "%SYSGEN_FUSIONWARE_BOOT_PXA25X%"=="1" set SYSGEN_FUSIONWARE_BOOT=1
if "%SYSGEN_FUSIONWARE_OAL_PXA25X%"=="1" set SYSGEN_FUSIONWARE_OAL=1
if "%SYSGEN_FUSIONWARE_PXA25X_FFUART1%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1
if "%SYSGEN_FUSIONWARE_PXA25X_BTUART2%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1
if "%SYSGEN_FUSIONWARE_PXA25X_STUART2%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1

if "%BSP_FUSIONWARE_PXA25X_SERIAL%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
:noPXA25X_1 

@REM -- Intel PXA27X specific
if not "%__CPU_PXA27X%"=="1" goto noPXA27X_1
if "%SYSGEN_FUSIONWARE_BOOT_PXA27X%"=="1" set SYSGEN_FUSIONWARE_BOOT=1
if "%SYSGEN_FUSIONWARE_OAL_PXA27X%"=="1" set SYSGEN_FUSIONWARE_OAL=1

@REM use the existing PXA25X serial drivers for PXA27X
if "%SYSGEN_FUSIONWARE_PXA25X_FFUART1%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1
if "%SYSGEN_FUSIONWARE_PXA25X_BTUART2%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1
if "%SYSGEN_FUSIONWARE_PXA25X_STUART2%"=="1" SET SYSGEN_FUSIONWARE_PXA25X_SERIAL=1

if "%BSP_FUSIONWARE_PXA27X_SERIAL%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
:noPXA27X_1 

@REM -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

@REM -- Set up parent vars if child is present
if "%SYSGEN_FUSIONWARE_BOOTSTART_MONITOR%"=="1" set SYSGEN_FUSIONWARE_BOOT=1
if "%SYSGEN_FUSIONWARE_BOOTSTART_CUSTOM%"=="1" set SYSGEN_FUSIONWARE_BOOT=1

@REM -- always generate FusionWare.Device.lib if any of the others are requested
if "%SYSGEN_FUSIONWARE_BOOT%"=="1" SET SYSGEN_FUSIONWARE_DEVICE=1
if "%SYSGEN_FUSIONWARE_OAL%"=="1" SET SYSGEN_FUSIONWARE_DEVICE=1
if "%SYSGEN_FUSIONWARE_DFX%"=="1" SET SYSGEN_FUSIONWARE_DEVICE=1

@REM -- always include Exception handling and RTTI if using Fusionware code base
if "%SYSGEN_FUSIONWARE_BOOT%"=="1" SET SYSGEN_CPP_EH_AND_RTTI=1
if "%SYSGEN_FUSIONWARE_OAL%"=="1" SET SYSGEN_CPP_EH_AND_RTTI=1
if "%SYSGEN_FUSIONWARE_DFX%"=="1" SET SYSGEN_CPP_EH_AND_RTTI=1

if not "%SYSGEN_FUSIONWARE_BOOT%"=="1" goto noboot_1

@REM -- Use MONITOR based start if custom isn't specified
if "%SYSGEN_FUSIONWARE_BOOTSTART_CUSTOM%"=="1" goto doneBootStart_1
SET SYSGEN_FUSIONWARE_BOOTSTART_MONITOR=1
:doneBootStart_1
:noboot_1

@REM -- Set up Kitl DLL if any of the KITL drivers are selected
if "%BSP_FUSIONWARE_KITL_AX88796%"=="1" SET SYSGEN_FUSIONWARE_KITLDLL=1

if not "%SYSGEN_FUSIONWARE_AUTORUN%"=="1" goto noautorun_1
    SET SYSGEN_STOREMGR=1
    SET SYSGEN_SERVICES=1
:noautorun_1

@REM -- Serial drivers require exception handling support in the OS
if "%BSP_FUSIONWARE_MXL_SERIAL%"=="1" goto needeh_1
if "%BSP_FUSIONWARE_PXA25X_SERIAL%"=="1" goto needeh_1
goto noserial_1
:needeh_1
    SET SYSGEN_CPP_EH_AND_RTTI=1
:noserial_1

goto :EOF
@REM -- End of DoPass1 Subroutine
@REM -- =====================================================================================

@REM -- =====================================================================================
@REM --  Remarks:
@REM --     "pass2" is passed after most of CESYSGEN.BAT has RUN and it's auto dependency setup is completed
@REM --     Build up the FUSIONWARE_MODULES list for the makefile in _PUBLICROOT\FUSIONWARE\cesysgen
@REM -- 
@REM --  Implementation Notes:
@REM --       Be careful to list items in FUSIONWARE_MODULES in proper order so dependents are built first.
@REM --       To avoid label name clashes ALWAYS Use  a trailing _2 for all goto labels in this section
@REM -- 
@REM -- =====================================================================================
:DoPass2

@REM -- If both KITLDLL and static lib are set then DLL wins.
if "%SYSGEN_FUSIONWARE_KITLDLL%"=="1" set SYSGEN_FUSIONWARE_KITLSTATIC=

if "%SYSGEN_FUSIONWARE_KITLSTATIC%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% Fusionware_KITL
if "%SYSGEN_FUSIONWARE_OAL%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% FusionWare_OAL
if "%SYSGEN_FUSIONWARE_BOOT%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% FusionWare_BOOT
if "%SYSGEN_FUSIONWARE_DEVICE%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% FusionWare_DEVICE

@REM -- Check for KITL DLLs
if "%SYSGEN_FUSIONWARE_KITL_AX88796%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% Kitl

@REM -- Set Kitl components based on specified NIC 
if "%SYSGEN_FUSIONWARE_KITL_AX88796%"=="1" set FUSIONWARE_KITL_COMPONENTS=%FUSIONWARE_KITL_COMPONENTS% AX88796Kitl

@REM -- second level - common dependencies for all drivers
@REM -- and the common driver support 
if not "%SYSGEN_DEVICE%"=="1" goto nodevmgr_2

if "%BSP_FUSIONWARE_NDIS_CS8900A%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_NDIS_AX88796%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_POWER_BUTTON%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_USB_TD242%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_NAND_FLASH%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_EXAR_UART%"=="1" SET SYSGEN_FUSIONWARE_DFX=1
if "%BSP_FUSIONWARE_UART_16550%"=="1" SET SYSGEN_FUSIONWARE_DFX=1

if "%BSP_FUSIONWARE_POWER_BUTTON%"=="1" SET SYSGEN_PM=1

@REM -- Common CPU Neutral Device Drivers
if "%SYSGEN_FUSIONWARE_DFX%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% FusionWare_DFX

if "%BSP_FUSIONWARE_CS8900A_NDIS%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% Ends4isa
if "%BSP_FUSIONWARE_AX88796_NDIS%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% AX88796NDIS
if "%BSP_FUSIONWARE_POWER_BUTTON%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% PWRBTN
if "%BSP_FUSIONWARE_NAND_FLASH%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% NandFlashD
if "%BSP_FUSIONWARE_EXAR_UART%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% ExarSer
if "%BSP_FUSIONWARE_UART_16550%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% UART16550
if "%BSP_FUSIONWARE_USB_TD242%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% FWTD242
if "%SYSGEN_FUSIONWARE_AUTORUN%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% AutoRun

:nodevmgr_2

if "%SYSGEN_FUSIONWARE_KITLSTATIC%"=="1" set FUSIONWARE_KITL_COMPONENTS=%FUSIONWARE_KITL_COMPONENTS% KitlStatic
if "%SYSGEN_FUSIONWARE_KITLDLL%"=="1" set FUSIONWARE_KITL_COMPONENTS=%FUSIONWARE_KITL_COMPONENTS% KitlDllMain

if not "%SYSGEN_TOUCH%"=="1" goto notouch_2
if "%BSP_FUSIONWARE_SPLITTOUCH%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% SplitADCTouch
:notouch_2

@REM -- Public samples
if "%SYSGEN_FUSIONWARE_BOOTSTART_MONITOR%"=="1" SET FUSIONWARE_BOOT_COMPONENTS=%FUSIONWARE_BOOT_COMPONENTS% FusionWare_Boot_Startup

@REM -- check CPU specific dependencies
@REM -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@REM -- Freescale i.MXL
if not "%__CPU_iMXL%"=="1" goto nomxl_2
if "%SYSGEN_FUSIONWARE_BOOT_IMXL%"=="1" set FUSIONWARE_BOOT_COMPONENTS=%FUSIONWARE_BOOT_COMPONENTS% iMXLBoot
if "%SYSGEN_FUSIONWARE_OAL_IMXL%"=="1" set FUSIONWARE_OAL_COMPONENTS=%FUSIONWARE_OAL_COMPONENTS% iMXLOAL
if "%SYSGEN_FUSIONWARE_DEVICE%"=="1" set FUSIONWARE_DEVICE_COMPONENTS=%FUSIONWARE_DEVICE_COMPONENTS% iMXLDevice
 
@REM -- Add i.MXL On-Chip drivers to the list of modules if selected
if "%SYSGEN_FUSIONWARE_MXL_SERIAL%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% MxlSerial 
:nomxl_2

@REM -- Intel PXA25X
if not "%__CPU_PXA25X%"=="1" goto noPXA25X_2
if "%SYSGEN_FUSIONWARE_BOOT_PXA25X%"=="1" set FUSIONWARE_BOOT_COMPONENTS=%FUSIONWARE_BOOT_COMPONENTS% PXA25XBoot
if "%SYSGEN_FUSIONWARE_OAL_PXA25X%"=="1" set FUSIONWARE_OAL_COMPONENTS=%FUSIONWARE_OAL_COMPONENTS% PXA25XOAL
if "%SYSGEN_FUSIONWARE_DEVICE%"=="1" set FUSIONWARE_DEVICE_COMPONENTS=%FUSIONWARE_DEVICE_COMPONENTS% PXA25XDevice
 
:noPXA25X_2

@REM -- Intel PXA27X
if not "%__CPU_PXA27X%"=="1" goto noPXA27X_2
if "%SYSGEN_FUSIONWARE_BOOT_PXA27X%"=="1" set FUSIONWARE_BOOT_COMPONENTS=%FUSIONWARE_BOOT_COMPONENTS% PXA27XBoot
if "%SYSGEN_FUSIONWARE_OAL_PXA27X%"=="1" set FUSIONWARE_OAL_COMPONENTS=%FUSIONWARE_OAL_COMPONENTS% PXA27XOAL
if "%SYSGEN_FUSIONWARE_DEVICE%"=="1" set FUSIONWARE_DEVICE_COMPONENTS=%FUSIONWARE_DEVICE_COMPONENTS% PXA27XDevice
if "%BSP_FUSIONWARE_PXA27X_HCD%"=="1" set FUSIONWARE_MODULES=%FUSIONWARE_MODULES% PXA27Xohci2
:noPXA27X_2

@REM -- Add PXA25X On-Chip drivers to the list of modules if selected
if "%BSP_FUSIONWARE_PXA25X_SERIAL%"=="1" SET FUSIONWARE_MODULES=%FUSIONWARE_MODULES% PXA25XSerial 

call :DoReport
@REM -- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
goto :EOF
@REM -- End of DoPass2 Subroutine
@REM -- =====================================================================================

:DoReport
if "%FUSIONWARE_MODULES%"=="" goto :EOF
echo =====================================================================================
echo                          ** FusionWare::BSP Inside! **
echo -------------------------------------------------------------------------------------
echo FUSIONWARE_MODULES           = %FUSIONWARE_MODULES%
echo FUSIONWARE_OAL_COMPONENTS    = %FUSIONWARE_OAL_COMPONENTS%
echo FUSIONWARE_BOOT_COMPONENTS   = %FUSIONWARE_BOOT_COMPONENTS%
echo FUSIONWARE_DEVICE_COMPONENTS = %FUSIONWARE_DEVICE_COMPONENTS%
echo FUSIONWARE_DFX_COMPONENTS    = %FUSIONWARE_DFX_COMPONENTS%
echo FUSIONWARE_KITL_COMPONENTS   = %FUSIONWARE_KITL_COMPONENTS%
echo =====================================================================================
goto :EOF


